﻿using System;
using System.Web;

namespace Smarly.Web.Helpers
{
	public static class HttpRequestBaseExtentions
	{
/*
		 public static string FullDomain(this HttpRequest request)
		 {
			 var requestUrl = request.Url;
			 return requestUrl.Scheme + "://" + requestUrl.Host + (requestUrl.Port == 80 ? string.Empty : ":" + requestUrl.Port);
		 }
*/
		 public static string FullDomain(this HttpRequestBase request)
		 {
			 var requestUrl = request.Url;
			 return requestUrl.Scheme + "://" + requestUrl.Host + (requestUrl.Port == 80 ? string.Empty : ":" + requestUrl.Port);
		 }
/*

		public static string FullUrl(this HttpRequest request, string relativeUrl)
		{
			return request.FullDomain() + relativeUrl;
		}
*/

		public static string FullUrl(this HttpRequestBase request, string relativeUrl)
		{
			Uri baseUri = new Uri(request.FullDomain());
			return new Uri(baseUri, relativeUrl).ToString();// request.FullDomain() + relativeUrl;
		}
	}
}